﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Millionaire;
using WindowsFormsApplication1.BLL;

namespace demobackground
{
    public partial class SettingPage : PhoneApplicationPage
    {
        NguoiChoiBLL nguoiChoiBLL;
        LinhVucBLL linhVucBLL;
        public SettingPage()
        {
            InitializeComponent();
            nguoiChoiBLL = new NguoiChoiBLL();
            linhVucBLL = new LinhVucBLL();            
            LoadDataToLbLinhVuc();
           // lbLinhVuc.IsSelectionEnabled = true;
        }

        

        private void LoadDataToLbLinhVuc()
        {
            List<LinhVuc> list = linhVucBLL.GetAll();
            list.Insert(0, new LinhVuc() { MaLinhVuc = 0, TenLinhVuc = "Tất cả" });
            lbLinhVuc.ItemsSource = list;
        }


        private void btnLinhVuc_Click(object sender, RoutedEventArgs e)
        {
            List<int> listLV = new List<int>();
            for (int i = 0; i < lbLinhVuc.SelectedItems.Count; i++)
            {
                listLV.Add(((LinhVuc)lbLinhVuc.SelectedItems[i]).MaLinhVuc);
            }            
            string maLV = "";
            for (int i = 0; i < listLV.Count; i++)
            {
                maLV += listLV[i] + ",";
            }
            
            App a = Application.Current as App;
            a.listLV = listLV;
            NavigationService.Navigate(new Uri("/MainPage.xaml",UriKind.Relative));
        }

        

        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            List<int> listLV = new List<int>();
            for (int i = 0; i < lbLinhVuc.SelectedItems.Count; i++)
            {
                listLV.Add(((LinhVuc)lbLinhVuc.SelectedItems[i]).MaLinhVuc);
            }
            string maLV = "";
            for (int i = 0; i < listLV.Count; i++)
            {
                maLV += listLV[i] + ",";
            }

            App a = Application.Current as App;
            a.listLV = listLV;
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
    }
}